import { _decorator, Component, director, log, tween, v3 } from 'cc';
import { AudioManager } from '../../framework/manager/AudioManager';
import { ResourceMgr } from '../../framework/manager/ResourceMgr';
const { ccclass, property } = _decorator;

@ccclass('BoomHome')
export class BoomHome extends Component {

    protected onLoad(): void {
        let logo = this.node.getChildByPath("UI_ROOT/Boom1")
        // Logo放大缩小
        tween(logo)
            .sequence(
                tween().to(1, { scale: v3(1.2, 1.2, 1) }),
                tween().to(1, { scale: v3(0.8, 0.8, 1) }))
            .repeatForever()
            .start()

        // 开始按钮
        let startBtn = this.node.getChildByPath("UI_ROOT/StartBtn")
        tween(startBtn)
            .by(1.2, { angle: -360 }, { easing: "cubicOut" })
            .repeatForever()
            .start()

        AudioManager.Instance.stop()
        AudioManager.Instance.playMusic("boom/sounds/bg")

        // 开始事件
        ResourceMgr.Instance.addButtonListen(startBtn, this, this.nav2Game);
    }

    /**
     * 跳转到Game
     */
    private nav2Game() {
        director.loadScene("BoomGame")
    }

}

